<template>
  <a-card class="ax_sticky_top">
    <template #title>
        系统评论列表
    </template>
    <template #extra>
      <a-tooltip title="前往帮助中心">
        <a class="system__icon" target="_blank">
          <QuestionCircleTwoTone/>
        </a>
      </a-tooltip>
    </template>
    <div class="mb-12 grid grid-cols-6 gap-4">
              <a-input
                  v-model:value="commentTable.query.author"
                  class="flex-1"
                  placeholder="请输入作者"
                  @press-enter="commentSearch"
                  allow-clear
              ></a-input>
      <div class="text-right">
        <a-button type="primary" @click="commentSearch">搜索</a-button>
      </div>
    </div>
    <a-flex justify="space-between" :align="'center'">
      <a-flex justify="space-between" :align="'center'">
        <a-flex :align="'center'" :gap="4">

          <div v-perm="'ax:comment:add'">
            <a-tooltip title="新建">
              <a-button type="primary" @click="commentCreate">
                <PlusOutlined/>
              </a-button>
            </a-tooltip>
          </div>

          <div v-perm="'ax:comment:edit'">
            <a-tooltip title="编辑">
              <a-button type="link" @click="commentEdit()" :disabled="commentTable.keys.length !== 1">
                <EditOutlined/>
              </a-button>
            </a-tooltip>
          </div>
          <div v-perm="'ax:comment:list'">
            <a-tooltip title="刷新">
              <a-button type="link" @click="commentList">
                <SyncOutlined/>
              </a-button>
            </a-tooltip>
          </div>
          <div v-perm="'ax:comment:remove'">
            <a-popconfirm
                title="确定要删除吗"
                :disabled="commentTable.keys.length === 0"
                placement="bottomRight"
                @confirm="commentDelete()"
            >
              <a-tooltip title="批量删除">
                <a-button danger type="link" :disabled="commentTable.keys.length === 0">
                  <DeleteOutlined/>
                </a-button>
              </a-tooltip>
            </a-popconfirm>
          </div>
        </a-flex>

      </a-flex>
      <a-flex>
        <div v-perm="'ax:comment:export'">
          <a-tooltip title="下载数据">
            <a-button type="link" @click="commentExport">
              <DownloadOutlined/>
            </a-button>
          </a-tooltip>
        </div>
        <div v-perm="'ax:comment:add'">
          <a-tooltip title="导入数据">
            <a-button type="link" @click="commentImport">
              <UploadOutlined/>
            </a-button>
          </a-tooltip>
        </div>

        <FieldVue :raw="commentRawColumns" v-model:columns="commentColumns"
                  :module-name="commentTable.moduleName"/>
        <div>
          <a-tooltip title="卡片模式" @click="commentTable.viewMode = 'card'"
                     v-if="commentTable.viewMode === 'table'">
            <a-button type="link">
              <OrderedListOutlined/>
            </a-button>
          </a-tooltip>

          <a-tooltip title="表格模式" @click="commentTable.viewMode = 'table'" v-else>
            <a-button type="link">
              <AppstoreAddOutlined/>
            </a-button>
          </a-tooltip>
        </div>
      </a-flex>
    </a-flex>
  </a-card>
</template>

<script setup lang="ts">
  import {
  } from '../../data/options';
  import FieldVue from '@/views/components/table/Field.vue';
  import {commentColumns, commentRawColumns} from '../../data/column';
  import {
          commentCreate,
          commentDelete,
          commentEdit,
          commentList,
          commentSearch,
          commentImport,
          commentExport
  } from '../../data/curd';
  import {commentTable} from '../../data/table';


</script>

<style lang="scss" scoped></style>


